package com.xcjh.opencv.rule.duiyuan;


import com.xcjh.opencv.ExeRule;
import com.xcjh.opencv.FindSimilarImage;
import com.xcjh.opencv.ImageUtil;
import com.xcjh.opencv.emuns.MatchImage;
import com.xcjh.opencv.rule.BaseRule;
import org.opencv.core.Core;
import org.springframework.stereotype.Component;

import java.awt.*;

@Component
public class Duiyuan implements BaseRule {
    @Override
    public String getRuleName() {
        return "对缘";
    }

    @Override
    public void run(Robot robot) throws Exception {
        //暂时不去去掉
        findAndClickPic(MatchImage.暂时不去, robot);
        ExeRule.delayByRobot(300, robot);
        //看看有没有打招呼
        if (findAndClickPic(MatchImage.打招呼, robot)) {
            findAndClickPic(MatchImage.暂时不去, robot);
            ExeRule.delayByRobot(2000, robot);
            //有就打个招呼
            System.out.println("########");
            dazhaohu(robot);
            System.out.println("#######执行完毕");
        } else {
            //干掉暂时不去
            findAndClickPic(MatchImage.暂时不去, robot);
            //然后下一个
            findAndClickPic(MatchImage.对缘下一个, robot);
        }

        ExeRule.delayByRobot(2500, robot);
    }

    private void dazhaohu(Robot robot) throws Exception {
//        exeRule(robot, "duiyuan/对缘打招呼.txt");
        //移动至输入框
        ExeRule.moveToByRobot(786, 866, robot);
        ExeRule.delayByRobot(100,robot);
        //按下3秒后弹起
        ExeRule.leftDownByRobot(1,robot);
        System.out.println("####################################");
        ExeRule.delayByRobot(3100,robot);
        ExeRule.leftUpByRobot(1,robot);
        //等待2秒粘贴
        ExeRule.delayByRobot(1300,robot);

        findAndClickPic(MatchImage.粘贴, robot);
        ExeRule.delayByRobot(861, robot);
        findAndClickPic(MatchImage.发送, robot);
        ExeRule.delayByRobot(1561, robot);
        ExeRule.moveToByRobot(711, 157, robot);
        ExeRule.leftClickByRobot(1, robot);
    }
}
